﻿using System;
using System.ComponentModel;

namespace SapaFinance.Domain.Model
{
    public class PaymentOrder
    {
        [DisplayName("Плательщик")]
        public BankAccountDetails Payer { get; private set; }

        [DisplayName("Получатель")]
        public BankAccountDetails Payee { get; private set; }

        [DisplayName("Дата оплаты")]
        public DateTime PaymentPeriod { get; private set; }

        [DisplayName("Сумма платежа")]
        public decimal PaymentAmount { get; private set; }

        [DisplayName("Тип валюты")]
        public CurrencyType CurrencyType { get; private set; }

        [DisplayName("Тип платежа")]
        public PaymentType PaymentType { get; private set; }

        [DisplayName("Налоговая ставка")]
        public TaxRate TaxRate { get; private set; }

        [DisplayName("Назначение платежа")]
        public string PaymentPurpose { get; private set; }

        [DisplayName("Автор заявки")]
        public AccountUser Author { get; private set; }

        [DisplayName("Статья бюджета")]
        public BudgetItem BudgetItem { get; private set; }

        [DisplayName("Получатель в кассе")]
        public AccountUser PayeeCash { get; private set; }

        [DisplayName("Номер заявки")]
        public int PaymentOrderNumber { get; private set; }

        [DisplayName("Дата создания")]
        public DateTime DateCreate{ get; private set; }

        [DisplayName("Дата акцептирования")]
        public DateTime DateAccept { get; private set; }

        [DisplayName("Кем подтверждена")]
        public AccountUser AcceptedBy{ get; private set; }

        [DisplayName("Дата удаления")]
        public DateTime DateDelete { get; private set; }

        [DisplayName("Кем удалена")]
        public  AccountUser DeletedBy { get; private set; }

         [DisplayName("Спецпримечание")]
        public  string Description { get; private set; }

        public bool IsAccepted
        {
            get { return DateAccept != null; }
        }

        public bool IsDeleted
        {
            get { return DateDelete != null; }
        }

        public PaymentOrder()
        {
            DateCreate = DateTime.Now;
        }
        public void SetPaymentDate(DateTime now)
        {
            PaymentPeriod = now;
        }

        public void SetPayer(BankAccountDetails payer)
        {
            Payer = payer;
        }

        public void SetPayee(BankAccountDetails payee)
        {
            Payee = payee;
        }

        public void SetPaymentAmount(decimal paymentAmount)
        {
            PaymentAmount = paymentAmount;
        }

        public void SetCurrencyType(CurrencyType currencyType)
        {
            CurrencyType = currencyType;
        }

        public void SetPaymentType(PaymentType paymentType)
        {
            PaymentType = paymentType;
        }

        public void SetTaxRate(TaxRate taxRate)
        {
            TaxRate = taxRate;
        }

        public void SetPaymentPurpose(string paymentPurpose)
        {
            PaymentPurpose = paymentPurpose;
        }

        public void SetAuthor(AccountUser author)
        {
            Author = author;
        }

        public void SetBudgetItem(BudgetItem budgetItem)
        {
            BudgetItem = budgetItem;
        }

        public void SetPayeeCash(AccountUser accountUser)
        {
            PayeeCash = accountUser;
        }

        public void SetPaymentOrderNumber(int number)
        {
            PaymentOrderNumber = number;
        }

        public void Accept(AccountUser accountUser)
        {
            DateAccept = DateTime.Now;
            AcceptedBy = accountUser;
        }

        public void Delete(AccountUser accountUser)
        {
            DateDelete = DateTime.Now;
            DeletedBy = accountUser;
        }

        public void SetDescription(string specialDescription)
        {
            Description = specialDescription;
        }
    }
}